

#ifndef REGFLAG_H__
#define REGFLAG_H__

/*###################### Macros ########################*/
#define set_flags() f_value=(sign_value<<7)|(zero_value<<6)|(aux_value<<4)|(parity_value<<2)|(carry_value) 

#define set_psw()   psw_value=(a_value<<8)|f_value
#define set_hl()    hl_value=(h_value<<8)|l_value
#define set_de()    de_value=(d_value<<8)|e_value
#define set_bc()    bc_value=(b_value<<8)|c_value

#define get_bc()    b_value=bc_value>>8; c_value=bc_value&0xff
#define get_de()    d_value=de_value>>8; e_value=de_value&0xff
#define get_hl()    h_value=hl_value>>8; l_value=hl_value&0xff
#define get_psw()   carry_value=psw_value&0x1; \
					parity_value=(psw_value>>2)&0x1; \
					aux_value=(psw_value>>4)&0x1; \
					zero_value=(psw_value>>6)&0x1; \
					sign_value=(psw_value>>7)&0x1; \
					a_value=psw_value>>8
					
#define set_sign_flag()   	sign_value=(a_value>>7)&0x1
#define set_zero_flag()  	zero_value=(a_value&0xff)?0:1
#define set_carry_flag()  	carry_value=(a_value>>8)&0x1
#define set_aux_flag(data) 	if(((a_value&0xf)+((data)&0xf))>0xF) aux_value=1; else aux_value=0
#define set_parity_flag() 	int ix,jx=0; \
						  	for(ix=0;ix<8;ix++){ \
								if(a_value&(1<<ix)) \
									jx++; \
						  	} \
						  	if(jx%2) parity_value=0; else parity_value=1
								
#define comp_carry()		if(carry_value) carry_value=0; else carry_value=1

/*###################### Globals #######################*/

extern gint sign_value,parity_value,carry_value,zero_value,aux_value;
extern gint pc_value,sp_value;
extern gint a_value,b_value,c_value,d_value,e_value,h_value,l_value,f_value;
extern gint mse_value,ei_value;
extern gint rst55_value,rst65_value,rst75_value;
extern gint mask55_value,mask65_value,mask75_value;

extern gint psw_value,bc_value,de_value,hl_value;
extern gint sid_value,sod_value,sde_value;

/*###################### functions ######################*/
extern GtkWidget *gsim_get_regflag_table( void );
extern void show_hide_regflag(void);
extern void gsim_set_registers(void);
extern void gsim_set_entries(void);
extern void reset_regflag(void);

#endif
